// This file is kept for backward compatibility but is no longer used
// The application now uses Neon PostgreSQL directly via the neon-db.ts file

import { createClient } from "@supabase/supabase-js"
import type { Database } from "./database.types"

// Create a single supabase client for the entire application
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!

if (!supabaseUrl || !supabaseAnonKey) {
  console.error("Missing Supabase environment variables")
}

// Create the client with automatic retries
export const supabase = createClient<Database>(supabaseUrl, supabaseAnonKey, {
  auth: {
    persistSession: true,
    autoRefreshToken: true,
  },
  global: {
    headers: {
      "x-application-name": "pumproom-chat",
    },
  },
})

// This function is kept for backward compatibility
export async function checkSupabaseConnection() {
  console.warn("checkSupabaseConnection is deprecated. Use checkDatabaseConnection from neon-db.ts instead.")
  return false
}

console.log("Supabase client initialized (deprecated)")
